﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>广东11选5</title>
    <style>
    	*{
			font-family: "微软雅黑";
			margin: 0px;
			padding: 0px;
			box-sizing: border-box;
		}
		html,body{
			width: 100%;
		}
		.content{
			width: 100%;
		}
    	.banner{
    		width: 100%;
    		height: 75px;
    		text-align: center;
    		padding: 8px;
    		background-size: cover;
    		text-align: center;
    	}
    	.banner .title{
    		float: right;
    		width: 30px;
    		height: 30px;
    	}
    	.banner .title p{
    		display: inline-block;
    		width: 30px;
    		height: 30px;
    		background-image: url(./image/vioce_u.png);
    		background-repeat: no-repeat;
			background-size: 30px;
			background-position: center;
    	}
    	.banner .title p.active{
    		background-image: url(./image/vioce_p.png);
    	}
    	.banner div{
    		height: 60px;
    		width: 300px;
    		margin: 5px auto;
    	}
    	.banner div span{
    		float: left;
    		width: 60px;
    		height: 60px;
    		background-image: url(./image/cqssc_numb.png);
    		background-size: cover;
    		overflow: hidden;
    	}
    	.banner div span section{
    		width: 50px;
    		height: auto;
    		overflow: hidden;
    		position: relative;
    		left: 0px;
    		top: 0px;
    	}
    	.banner div span p{
    		display: block;
    		height: 60px;
    		width: 60px;
    		font-size: 24px;
    		font-weight: bold;
    		line-height: 60px;
    		text-align: center;
    		color: #E67A07;
    	}
    </style>
</head>
<body>
    <div class="content">
    	<div id="jplayer"></div>
        <div class="banner">
        	<div class="title"><p id="playVioce" class="active"></p></div>
        	<div class="leto_numb">
        		<span><section id="numbOne"></section></span>
        		<span><section id="numbTwo"></section></span>
        		<span><section id="numbThr"></section></span>
        		<span><section id="numbFor"></section></span>
        		<span><section id="numbFve"></section></span>
        	</div>
    	</div>
    </div>
    <script src="./jplayer/jquery.min.js"></script>
	<script src="./jplayer/jquery.jplayer.js"></script>
    <script src="./jplayer/extend.js"></script>
    <script src="./jplayer/commFun.js"></script>
    <script>
        $(function(){
            var urlPrefix = "/";
//            var urlPrefix = "http:///localhost:1337/demo.web.blh.jacking.cn/";
			var stopTopData = null;
            //获取当前期次
            getCurrIssue();
            function getCurrIssue(){
            	$.ajaxFormat({
	                url:  urlPrefix + 'api/get_curr_issue'
	                ,dataType: 'json'
	                ,type: 'post'
	                ,data: {lot_type: 'gd11x5'}
	                ,success: function(d){
	                    //console.log('当前期次');
	                    //console.log(d)
	                    if(d.success == true){
	                    	var stopTime = new Date(d.time_endsale).getTime();
	                    	var nowTime = new Date(d.curr_time).getTime();
	                    	if(stopTime>nowTime){
	                    		$('.title').attr('data-prevId',d.previous_issue_id);
								calcLetoOpenTimer(d.curr_time,d.previous_time_openaward);
	                    	}else{
	                    		getCurrIssue();
	                    	}
	                    }else{
	                    	if(d.message.code == 400){
	                    		//window.location.href='login.html';
	                    	}else{
	                    		//window.commFun.showAlert(d.message.content)
	                    	}
	                    }
	                }
	            })
            }
            
            
			function calcLetoOpenTimer(currTime,openTime){
				var now = new Date(currTime).getTime();
				var open = new Date(openTime).getTime();
				setTimeout(function(){
					var openNumbTimer = setInterval(function(){
						$.ajaxFormat({
							url:  urlPrefix + 'api/get_award_issue'
							,dataType: 'json'
							,type: 'post'
							,data: {
								lot_type: 'gd11x5'
								,issue_id: $('.leto_prev').attr('data-prevId')
							}
							,success: function(d){
								//console.log('获取上一期的开奖号码');
								//console.log(d);
								if(d.success==true){
									if(d.openaward_num){
										$('#jplayer').jPlayer('stop');
										clearInterval(openNumbTimer);
										var openNumbArray = d.openaward_num.split(' ');
										stopTopData = {
											numbOne: openNumbArray[0]
											,numbTwo: openNumbArray[1]
											,numbThr: openNumbArray[2]
											,numbFor: openNumbArray[3]
											,numbFve: openNumbArray[4]
										}
									}
								}else{
									if(d.message.code==400){
										//window.location.href='login.html';
									}else{
										//window.commFun.showAlert(d.message.content)
									}
								}
							}
						})
					},3000)
				},(open - now))
			}
            
            animateCQSSCInit();
            function animateCQSSCInit(){
            	var letoNumbStr = '';
            	for(var i=1;i<12;i++){
            		letoNumbStr += '<p>'+(i<10?'0'+i:i)+'</p>';
            	}
            	$('.leto_numb span section').html(letoNumbStr);
            	$('.leto_numb span section').each(function(i,item){
            		someOneAnimate($(item));
            	})
            	
            	function someOneAnimate(_box){
            		var top = _box.height();
            		_box.animate({'top':'-'+top+'px'},1000,'linear');
            		var intervalTimer = setInterval(function(){
	            		_box.animate({'top':'0px'},10,'linear');
	            		setTimeout(function(){
	            			//console.log(stopTopData);
	            			if(stopTopData){
	            				clearInterval(intervalTimer)
								if(_box.attr('id')=='numbOne'){
									var stopTop = (stopTopData.numbOne-1)*60;
									_box.animate({'top':'-'+stopTop+'px'},200,'linear');
								}else if(_box.attr('id')=='numbTwo'){
									var stopTop = (stopTopData.numbTwo-1)*60;
									_box.animate({'top':'-'+stopTop+'px'},400,'linear');
								}else if(_box.attr('id')=='numbThr'){
									var stopTop = (stopTopData.numbThr-1)*60;
									_box.animate({'top':'-'+stopTop+'px'},600,'linear');
								}else if(_box.attr('id')=='numbFor'){
									var stopTop = (stopTopData.numbFor-1)*60;
									_box.animate({'top':'-'+stopTop+'px'},800,'linear');
								}else if(_box.attr('id')=='numbFve'){
									var stopTop = (stopTopData.numbFve-1)*60;
									_box.animate({'top':'-'+stopTop+'px'},1000,'linear');
								}
	            			}else{
	            				_box.animate({'top':'-'+top+'px'},1000,'linear');
	            			}
	            		},10)
	            	},1000);
            	}
           }
            
            playVioceByJplayer();
			function playVioceByJplayer(){
				$('#jplayer').jPlayer({
					ready: function (event) {
		            $(this).jPlayer("setMedia", {
		                title: "Bubble",
		                mp3: "./jplayer/mp3/cqssc.mp3"
			            }).jPlayer("play");
			        },
			        swfPath: "js",
			        supplied: "mp3",
			        wmode: "window",
			        smoothPlayBar: true,
			        keyEnabled: true,
			        remainingDuration: true,
			        toggleDuration: true,
			        loop: true
				})
				
				$('#playVioce').on('click',function(){
					var isPlayVioce = $('#playVioce').hasClass('active');
					if(isPlayVioce){
						$('#playVioce').removeClass('active');
						$('#jplayer').jPlayer('stop');
					}else{
						$('#playVioce').addClass('active');
						$('#jplayer').jPlayer('play');
					}
				})
			}
        })
    </script>
</body>
</html>